package com.dogdog.fragment;

import com.dogdog.activity.R;
import com.dogdog.activity.R.id;
import com.dogdog.activity.R.layout;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class Hand_found extends Fragment implements OnClickListener {

	private RelativeLayout titlebar;
	private TextView tv_title;
	private View tab1;
	private LinearLayout ly_meeting;
	private LinearLayout ly_location;
	private LinearLayout ly_place;
	private LinearLayout line1;
	private LinearLayout line2;
	private LinearLayout line3;
	private TextView tv_locaiton;
	private TextView tv_meeting;
	private TextView tv_place;
	private Hand_found_location hand_found_location;
	private Hand_found_meeting hand_found_meeting;
	private Hand_found_place hand_found_place;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		tab1 = inflater.inflate(R.layout.fragment_main_found, container, false);
		initView();
		setDefaultFragment();
		return tab1;
	}

	private void initView() {
		titlebar = (RelativeLayout) tab1.findViewById(R.id.rl_titlebar);
		tv_title = (TextView) tab1.findViewById(R.id.tv_title);
		tv_title.setText("发现");
		ly_location = (LinearLayout) tab1.findViewById(R.id.ly_locaiton);
		ly_meeting = (LinearLayout) tab1.findViewById(R.id.ly_meeting);
		ly_place = (LinearLayout) tab1.findViewById(R.id.ly_place);
		ly_location.setOnClickListener(this);
		ly_meeting.setOnClickListener(this);
		ly_place.setOnClickListener(this);
		line1 = (LinearLayout) tab1.findViewById(R.id.line1);
		line2 = (LinearLayout) tab1.findViewById(R.id.line2);
		line3 = (LinearLayout) tab1.findViewById(R.id.line3);
		tv_locaiton = (TextView)tab1.findViewById(R.id.tv_location);
		tv_meeting = (TextView)tab1.findViewById(R.id.tv_meeting);
		tv_place = (TextView)tab1.findViewById(R.id.tv_place);
	}

	private void setDefaultFragment() {
		FragmentManager fm = getFragmentManager();
		FragmentTransaction transaction = fm.beginTransaction();
		hand_found_location = new Hand_found_location();
		transaction.replace(R.id.found_frame, hand_found_location);
		transaction.commit();
	}

	@Override
	public void onClick(View v) {
		FragmentManager fm = getFragmentManager();
		FragmentTransaction transaction = fm.beginTransaction();
		switch (v.getId()) {
		case R.id.ly_locaiton:

				hand_found_location = new Hand_found_location();
			
			transaction.replace(R.id.found_frame, hand_found_location);
			tv_locaiton.setTextColor(getResources().getColor(R.color.theme));
			tv_place.setTextColor(getResources().getColor(R.color.black));
			tv_meeting.setTextColor(getResources().getColor(R.color.black));
			line1.setBackgroundColor(getResources().getColor(R.color.theme));
			line2.setBackgroundColor(getResources().getColor(R.color.white1));
			line3.setBackgroundColor(getResources().getColor(R.color.white1));
			break;
		case R.id.ly_meeting:

				hand_found_meeting = new Hand_found_meeting();

			transaction.replace(R.id.found_frame, hand_found_meeting);
			tv_locaiton.setTextColor(getResources().getColor(R.color.black));
			tv_place.setTextColor(getResources().getColor(R.color.black));
			tv_meeting.setTextColor(getResources().getColor(R.color.theme));
			line1.setBackgroundColor(getResources().getColor(R.color.white1));
			line2.setBackgroundColor(getResources().getColor(R.color.theme));
			line3.setBackgroundColor(getResources().getColor(R.color.white1));
			break;
		case R.id.ly_place:

				hand_found_place = new Hand_found_place();

			transaction.replace(R.id.found_frame, hand_found_place);
			tv_locaiton.setTextColor(getResources().getColor(R.color.black));
			tv_place.setTextColor(getResources().getColor(R.color.theme));
			tv_meeting.setTextColor(getResources().getColor(R.color.black));
			line1.setBackgroundColor(getResources().getColor(R.color.white1));
			line2.setBackgroundColor(getResources().getColor(R.color.white1));
			line3.setBackgroundColor(getResources().getColor(R.color.theme));
			break;

		}
		transaction.commit();
	}

}
